package jp.tkym.labs.swing3d.drawer;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;

public class DrawPolygon implements DrawG2D{
	private Color color;
	private Point[] points;
	DrawPolygon(Color color, Point... points){
		this.color = color;
		this.points = points;
	}
	
	@Override
	public void draw(Graphics2D g2d) {
		Color oldColor = g2d.getColor();
		g2d.setColor(color);
		Polygon polygon = new Polygon();
		for(Point p : points)
			polygon.addPoint(p.x, p.y);
		g2d.fillPolygon(polygon);
		g2d.setColor(oldColor);
	}
}
